// $codepro.audit.disable numericLiterals, variableShouldBeFinal
/* Copyright (c) 2011 Team A CS2340. All rights reserved.*/

package edu.gatech.teama.doctorsoffice.client.view;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * AddUserDialog.java
 * @author unknown
 * @version 1.0
 */
public class AddUserDialog extends JDialog {
	/**
	 * JPanel contentPane1
	 */
	private final JPanel contentPanel = new JPanel();

	/**
	 * AddUserPanel panel
	 */
	private final AddUserPanel panel;;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			AddUserDialog dialog = new AddUserDialog();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); // $codepro.audit.disable staticMemberAccess
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public AddUserDialog() { // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.constructorsOnlyInvokeFinalMethods
		setBounds(100, 100, 450, 460);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setLayout(new FlowLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		
		{ // $codepro.audit.disable bracePosition
			panel = new AddUserPanel();
			contentPanel.add(panel);
		}
		{ // $codepro.audit.disable bracePosition
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{ // $codepro.audit.disable bracePosition
				JButton okButton = new JButton("OK");
				okButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						okPressed();
					}
				});
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
			{ // $codepro.audit.disable bracePosition
				JButton cancelButton = new JButton("Cancel");
				cancelButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						cancelPressed();
					}
				});
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
			}
		}
	}
	
	/**
	 * ok pressed
	 */
	private void okPressed() {
		panel.okPressed();
		this.setVisible(false);
	}
	
	/**
	 * cancel pressed
	 */
	private void cancelPressed() {
		this.setVisible(false);
		this.dispose();
	}

}
